import {useState,useEffect} from 'react'
import axios from 'axios'
export default function useRequest(url){
    const [data,setData]=useState({})
    const [isLoading,setLoading]=useState(false)
    const [error,setError]=useState({})
    useEffect(()=>{
        setLoading(true)
        axios({
            url:url
        }).then(response=>{
            setData(response)
        }).catch(error=>{
            setError(error)
        }).finally(()=>{
            setLoading(false)
        })
    },[])
    return [isLoading,data,error]
}